package leetcode;

/**
 * @Project : algorithm-learning-java
 * @Package : leetcode
 * @Author : Ruoyu Wang
 * @User : Momenta
 * @DateTime : 2024/1/15 16:15
 */
public class Q0300 {
    public int lengthOfLIS(int[] nums) {
        int res = 1;
        int[] f = new int[nums.length];
        for (int i = 0; i < f.length; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[j] < nums[i]) {
                    f[i] = Math.max(f[i], f[j] + 1);
                    res = Math.max(f[i] + 1, res);
                }
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Q0300 sl = new Q0300();
        int[] nums = {10, 9, 2, 5, 3, 7, 101, 18};
        System.out.println(sl.lengthOfLIS(nums));
    }
}
